﻿using System;
using System.IO;
using System.Web;
using System.Text;
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Serialization;
using System.Data.Objects;
 
using System.Linq;
namespace VideoNetApplication.Common.Extension
{
    public static class JsonHelper
    {

        public static string ToJsonItem(this object item)
        {
            return JsonConvert.SerializeObject(item, new IsoDateTimeConverter());
        }


        public static T FromJsonTo<T>(this string jsonString)
        {
            return JsonConvert.DeserializeObject<T>(jsonString, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore });
        }

        public static string ToTraceString<T>(this IQueryable<T> t)
        {
            ObjectQuery<T> oqt = t as ObjectQuery<T>;
            if (oqt != null)
                return oqt.ToTraceString();
            return "";
        }



    }
}
